<?php
// использовать handler_comments и перенести в него метод Agr_getCommentsWithoutTree
class Action_Community_ShowCommentsRss extends RL_Handler
{

	protected function init() {
		$this->rh->UseClass('RL_CyrDate');
		$this->acl_assistant = $this->module->aa;

		$this->data = $this->acl_assistant->getInfo();
		$this->acl_assistant->getAvailableOperations();
		
		$this->ctx->mm->setAclAssistant( $this->acl_assistant );

		$this->m_fc = $this->ctx->mm->getModel("FlatComments", "m");
		
		$this->data['id_item'] = $this->params['id_item'];
		if ($this->data['id_item']) {
			$this->id_item = $this->data['id_item'];
		}

		if ($this->data['tdi_oid']) {
			$this->tdis[] = $this->data['tdi_oid'];
		}

		// --- user --- {{{
		if (isset($this->params['user_url'])) {
			$user_url = $this->params['user_url'];
			$user = $this->rh->ctx->store->find( 'select objects where user.oid=:0', array($user_url))->next();
			$this->user = $user;
		}
		// --- user --- }}}
	}

	public function process ()
	{
		$aa = &$this->acl_assistant;
		$aa->checkDeletions(array($this, "shutdown") );
		
		$comments = $this->m_fc->getCommentsWithoutTree($this->id_item, $this->tdis, NULL, $this->user->id, $aa->acl_data['comity_oid']);

		$view = $this->rh->views->findByName($this->params['view']);
		$view->data = $aa->template_data;
		$view->data['tdi'] = $this->data['tdi']->data;
		
		if ($comments) {
			$view->getMeta()->setLastModified( $comments[0]['mtime']->mktime() );
			$view->data['comments'] = $comments;
		} else $view->data['message'] = "В этой ленте нет сообщений.";

		$this->rh->response->setContent( $view );
	} // end of function execute

}
